<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<style type="text/css">
.ddl2beanButton{
	padding-left:5px;
	padding-top:5px;
}
.ddl2beanContent{
	padding-left:5px;
}
</style>

<script type="text/javascript">
var ddl2beanStep = 1;
var ddl2beanFrom3 = false;

$(function(){
	$('#ddl2besn_prev').hide();
		$('#ddl2bean_prev').hide();
		$('#ddl2bean_step2').css('display', 'none');
		$('#ddl2bean_step3').css('display', 'none');
});

function ddl2Bean(step){
	if(step == 2){
		if(!$.trim($('#ddl4bean').val())){
			showErrorMessage('请输入ddl语句');
			ddl2beanStep--;
			return;
		}

		$('#ddl2bean_step1').css('display', 'none');
		$('#ddl2bean_step2').css('display', 'block');
		$('#ddl2bean_step3').css('display', 'none');
		
		$('#ddl2bean_step2').show();
		if(!ddl2beanFrom3){
			$('#ddl2bean_step2').load('page/ddl2bean_step2.dox', {'ddl':$('#ddl4bean').val()});
		}
	
		$('#ddl2bean_prev').show();
		$('#ddl2bean_next').show();
		$('#ddl2bean_clear').hide();	
	
		$('#ddl2bean_next').val('生成');
	}else if(step == 3){
		$.ajax({
			type: "post",
			dataType: "html",
			url: 'page/ddl2bean_step3.dox',
			data: $('#ddl2bean_form').serialize(),
			success: function(data){
				ddl2beanFrom3 = true;
				
				$('#ddl2bean_step1').css('display', 'none');
				$('#ddl2bean_step2').css('display', 'none');
				$('#ddl2bean_step3').css('display', 'block');

				$('#ddl2bean_next').val('返回');
				
				$('#ddl2bean_step3').html(data);
			},
			error: function(data){
				showErrorMessage('生成失败');
			}
		});
	}else{
		$('#ddl2bean_step1').css('display', 'block');
		$('#ddl2bean_step2').css('display', 'none');
		$('#ddl2bean_step3').css('display', 'none');
		
		$('#ddl2bean_prev').hide();
		$('#ddl2bean_next').show();
		$('#ddl2bean_clear').show();
		
		$('#ddl2bean_next').val('下一步');
		
		ddl2beanFrom3 = false;
		ddl2beanStep = 1;
	}
}
</script>

<h1>根据建表语句(DDL)生成域对象</h1>

<div id="ddl2bean_step1" class="ddl2beanContent">
<h2>步骤1：输入DDL</h2>
<div>点击&nbsp;<a target="_blank" href="ddl_demo.html">这里</a>&nbsp;查看ddl示例</div>
<table>
	<tr>
		<td style="width:50%">域对象所在模块的名字<input id="ddl2bean_domainModule" type="text" placeholder="common"/></td>
	</tr>
</table>
<ul>
<li>必须只有一个自增主键</li>
</ul>
<textarea id="ddl4bean" style="width:90%;height:500px"></textarea><br/>
</div>

<div id="ddl2bean_step2" class="ddl2beanContent">
<img alt="请稍候..." src="resources/images/loading.gif">
</div>

<div id="ddl2bean_step3" class="ddl2beanContent">
<img alt="请稍候..." src="resources/images/loading.gif">
</div>

<div class="ddl2beanButton">
<input type="button" id="ddl2bean_prev" value="上一步" onclick="ddl2Bean(--ddl2beanStep);"/>
<input type="button" id="ddl2bean_next" value="下一步" onclick="ddl2Bean(++ddl2beanStep);"/>
<input type="button" id="ddl2bean_clear" value="清空" onclick="clearInput('#ddl4bean');"/>
</div>
